package com.zy.explore.pay.interfaces.facade.v1;

import com.zy.explore.common.interfaces.frm.CommonIdFrm;
import com.zy.explore.common.interfaces.frm.CommonIdsFrm;
import com.zy.explore.pay.interfaces.assembler.PayAssembler;
import com.zy.explore.pay.interfaces.feign.PayFeign;
import com.zy.explore.pay.interfaces.frm.PayFrm;
import com.zy.explore.pay.interfaces.vo.PayVO;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zy.explore.common.interfaces.vo.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 支付订单表(表t_pay)Facade门面
 *
 * @author 中国印
 * @date 2021-09-21 01:27:30
 */
@Api(tags = {"支付订单表Facade"})
@RestController
@RequestMapping("/pay")
public class PayFacade implements PayFeign {

    @Resource
    private PayAssembler assembler;

    /**
     * 新增数据
     *
     * @param frm 待新增的frm对象
     * @return 成功返回新增后的VO对象，失败返回null
     */
    @Override
    @ApiOperationSupport(author = "🇨🇳中国印🇨🇳", order = 10,
            ignoreParameters = {"id", "createTime", "createTimeBegin", "createTimeEnd", "updateTime",
                    "updateTimeBegin", "updateTimeEnd", "sortFields", "pageNum", "pageSize"}
    )
    @ApiOperation("1新增数据")
    @PostMapping("/insert")
    public PayVO insert(@RequestBody @Validated PayFrm frm) {
        return assembler.insert(frm);
    }

    /**
     * 删除数据
     *
     * @param frm 主键frm对象
     * @return 1:删除成功 其他:删除失败
     */
    @Override
    @ApiOperationSupport(author = "🇨🇳中国印🇨🇳", order = 20)
    @ApiOperation("2删除数据")
    @PostMapping("/delete")
    public Integer delete(@RequestBody @Validated CommonIdFrm frm) {
        return assembler.delete(frm);
    }

    /**
     * 更新数据
     *
     * @param frm 待更新的frm对象
     * @return 成功返回更新后的VO对象，失败返回null
     */
    @Override
    @ApiOperationSupport(author = "🇨🇳中国印🇨🇳", order = 30, ignoreParameters = {"createTime", "createTimeBegin",
            "createTimeEnd", "updateTime", "updateTimeBegin", "updateTimeEnd", "sortFields", "pageNum",
            "pageSize"}
    )
    @ApiOperation("3更新数据")
    @PostMapping("/update")
    public PayVO update(@RequestBody @Validated PayFrm frm) {
        return assembler.update(frm);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param frm 主键Frm对象
     * @return 成功返回对应ID的VO对象，失败返回null
     */
    @Override
    @ApiOperationSupport(author = "🇨🇳中国印🇨🇳", order = 40)
    @ApiOperation("4根据主键查询数据")
    @PostMapping("/findById")
    public PayVO findById(@RequestBody @Validated CommonIdFrm frm) {
        return assembler.findById(frm);
    }

    /**
     * 通过主键批量查询数据集合
     *
     * @param frm 主键集合Frm对象
     * @return 成功返回对应ID的VO对象，失败返回空集合
     */
    @Override
    @ApiOperationSupport(author = "🇨🇳中国印🇨🇳", order = 50)
    @ApiOperation("5根据主键集批量查询数据")
    @PostMapping("/findByIds")
    public List<PayVO> findByIds(@RequestBody @Validated CommonIdsFrm frm) {
        return assembler.findByIds(frm);
    }

    /**
     * 根据条件获取数据集
     *
     * @param frm 查询条件对象
     * @return 成功返回满足条件的数据集合，失败返回空集合
     */
    @Override
    @ApiOperationSupport(author = "🇨🇳中国印🇨🇳", order = 60, ignoreParameters = {"pageNum", "pageSize"})
    @ApiOperation("6根据条件查询数据集")
    @PostMapping("/getList")
    public List<PayVO> getList(@RequestBody @Validated PayFrm frm) {
        return assembler.getList(frm);
    }

    /**
     * 根据条件查询数据分页
     *
     * @param frm 查询条件参数
     * @return 成功返回满足条件的分页，失败返回空页
     */
    @Override
    @ApiOperationSupport(author = "🇨🇳中国印🇨🇳", order = 70)
    @ApiOperation("7根据条件查询数据分页")
    @PostMapping("/getPageInfo")
    public PageVO<PayVO> getPageInfo(@RequestBody @Validated PayFrm frm) {
        return assembler.getPageInfo(frm);
    }
}

